#include <stdbool.h>
#include <stdio.h>
#include <string.h>

#define STACK_SIZE 100

char contents[STACK_SIZE];
int top = 0;

void make_empty(void){
	top = 0;
}

bool is_empty(void){
	return top == 0;
}

bool is_full(void){
	return top == STACK_SIZE;
}

void push(char c){
	if (is_full()){
		printf("stack overflow!");
	} else {
		contents[top++] = c;
	}
}

char pop(){
	if (is_empty()){
		printf("stack underflow!");
	} else {
		return contents[--top];
	}
}



int main(){
	printf("Enter parentesse and/or braces: ");
	char c ;
	bool isMatch = true;
	for(;;){
		c = getchar();
		if (c == '(' || c == '{'){
			push(c);
		} else if (c == ')'){
			char temp = pop();
			if (temp != '('){
				isMatch = false;
				break;
			} else
					continue;
		} else if (c == '}'){
			if (pop() != '{'){
				isMatch = false;
				break;
			} else 
					continue;
		}
		if (c == '\n')
			break;
	}
	if (isMatch && top == 0) 
		printf("Parentesse/braces are RIGHT\n");
	else
		printf("Parentesse/braces are WRONG\n");
}
